package com.visualexpress.count;

import java.util.List;

import com.visualexpress.dao.ShipmentDAO;
import com.visualexpress.domain.Shipment;

public class CountAll {
	
	public static void addShipment(Shipment shipment) {
		CountLocationAvertime.addShipment(shipment);
		CountRouteInfo.addShipment(shipment);
		ShipmentDAO shipmentDAO = new ShipmentDAO();
		shipment.setIsCounted(true);
		shipmentDAO.attachDirty(shipment);
	}
	
	
	public static void bulkCountShipments() {
		ShipmentDAO shipmentDAO = new ShipmentDAO();
		Shipment shipmentExample = new Shipment();
		shipmentExample.setState(true);
		shipmentExample.setIsCounted(false);
		List<Shipment> lstShipment = shipmentDAO.findByExample(shipmentExample);
		for(Shipment shipment : lstShipment) {
			CountLocationAvertime.addShipment(shipment);
			CountRouteInfo.addShipment(shipment);
			shipment.setIsCounted(true);
			shipmentDAO.attachDirty(shipment);
		}
	}
}
